package com.jic.market.controller.manage;

import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.market.entity.Tag;
import com.jic.market.request.TagRequest;
import com.jic.market.response.TagResponse;
import com.jic.market.service.TagService;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/tag")
public class TagController {
    @Autowired
    private TagService tagService;

    @ApiOperation(value = "列表查询")
    @RequestMapping(value = "queryPage", method = RequestMethod.POST)
    public RestResult<PageResult<TagResponse>> queryPage(@RequestBody TagRequest request) {

        return tagService.queryPage(request);
    }

    @ApiOperation(value = "新增标签")
    @RequestMapping(value = "addTag", method = RequestMethod.POST)
    public RestResult<Integer > addTag(@RequestBody Tag request) {

        return tagService.addTag(request);
    }

    @ApiOperation(value = "列表查询无分页")
    @RequestMapping(value = "getTagList", method = RequestMethod.POST)
    public RestResult<PageResult<TagResponse>> getTagList(@RequestBody Tag request) {

        return tagService.getTagList(request);
    }

    @ApiOperation(value = "编辑标签")
    @RequestMapping(value = "editTag",method = RequestMethod.POST)
    public RestResult<Long> editTag(@RequestBody Tag request){
        return tagService.editTag(request);
    }

    @ApiOperation(value = "删除标签")
    @RequestMapping(value = "delTag",method = RequestMethod.POST)
    public RestResult<Long> detTag(@RequestBody Tag reuqest){
        return tagService.delTag(reuqest);
    }
}
